// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import {
	share
} from "./common/mixin.js"

import {
	$http
} from '@escook/request-miniprogram'


Vue.mixin(share)
Vue.config.productionTip = false
uni.$http = $http

//需要显示提示信息直接调用uni.$showMsg('要显示的信息')
uni.$showMsg = function(title = '数据加载失败', duration = 2000) {
	uni.showToast({
		title,
		duration,
		icon: 'none'
	})
}

//请求头
// $http.baseUrl = 'https://testtxxzdata.tingxiangzu.com'
$http.baseUrl = 'https://txxzdata.tingxiangzu.com'

//请求前
$http.beforeRequest = function(options) {
	if (options.url.indexOf('/Auth') !== -1) {
		uni.showLoading({
			title: '登录中'
		})
	} else if (options.url.indexOf('/Index') !== -1) {
		uni.showLoading({
			title: '正在加载...'
		})
	} else if (options.url.indexOf('/Goods') !== -1 || options.url.indexOf('/indexList') !== -1) {
		uni.showLoading({
			title: '正在加载...'
		})
	} else if (options.url.indexOf('/Order') !== -1 || options.url.indexOf('/Activity') !== -1) {
		options.header = {
			token: getApp().globalData.token
		}
	}
	//console.log(options)
}

//请求后
$http.afterRequest = function(res) {
	uni.hideLoading()
}

App.mpType = 'app'

const app = new Vue({
	...App,
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
